<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>信息展示页</title>


	<style>
		table,td,th{
			border: aquamarine 1px solid;
			border-collapse: collapse;
		}
	</style>

	<script src="js/jquery-3.6.0.min.js"></script>
	<script src="js/axios-0.18.0.js"></script>

</head>
<body>
	<center>
		<table>
			<thead>
				<tr>
					<th>id</th>
					<th>goods_name</th>
					<th>goods_price</th>
					<th>goods_img</th>
					<th>goods_stock</th>
				</tr>
			</thead>
			<tbody id="tbody1">

			</tbody>
		</table>
	</center>
</body>

<script>

	$(function(){
		axios.get("getLimit.do?page=1").then(function(response){
			let arr = response.data;  // 返回的是一个数组  因为数据库里每一行数据就是一个商品信息
			for (let i = 0;i < arr.length;i++){
				createTr(arr[i]);
			}
		});
	});


	function createTr(e){
		let tdId = $("<td></td>").text(e.id);
		let tdName = $("<td></td>").text(e.goods_name);
		let tdPrice = $("<td></td>").text(e.goods_price);
		let tdImg = $("<td></td>").text(e.goods_img);
		let tdStock = $("<td></td>").text(e.goods_stock);
		let tr1 = $("<tr></tr>").append(tdId).append(tdName).append(tdPrice).append(tdImg).append(tdStock);
		$("#tbody1").append(tr1);
	}


</script>



</html>